package band.wukong.practice.mina.quickstart.sumup.codec;

import band.wukong.practice.mina.quickstart.sumup.message.AddMessage;
import band.wukong.practice.mina.quickstart.sumup.message.ResultMessage;
import org.apache.mina.filter.codec.demux.DemuxingProtocolCodecFactory;

/**
 * Desc:
 * author: wukonggg@139.com
 */
public class SumUpProtocolCodecFactory extends DemuxingProtocolCodecFactory {

    public SumUpProtocolCodecFactory(boolean server) {

        // Server
        if (server) {
            super.addMessageDecoder(AddMessageDecoder.class);
            super.addMessageEncoder(ResultMessage.class, ResultMessageEncoder.class);
        }
        // Client
        else {
            super.addMessageDecoder(ResultMessageDecoder.class);
            super.addMessageEncoder(AddMessage.class, AddMessageEncoder.class);
        }
    }
}
